Skip to content

fix(id): refuse negative peers --depth at parse and crawl entry (#2125) - #4093

Merged
dezren39 merged 1 commit into
mainfrom
queue/5101-2125-negative-peer-depth
Nov 2, 2026
Merged

dezren39 merged 1 commit into
mainfrom
queue/5101-2125-negative-peer-depth

Conversation

@dezren39

@dezren39 dezren39 commented Nov 2, 2026 •

Copy link
Copy Markdown
Member

Implements the contract pinned by triage task 3132 on #2125 (queue task 5101): negative peers --depth is refused instead of silently selecting an unlimited crawl.

Changes (pkgs/id)

  • src/cli.rs: --depth gets a clap range parser (value_parser!(i32).range(0..)) plus allow_negative_numbers, so both --depth=-1 and --depth -1 reach the parser and are refused at parse time with an error naming --depth. Depths 0/1/2 parse unchanged.
  • src/commands/peers.rs: cmd_peers and crawl_peers both bail on negative depth before any networking; the depth < 0 → i32::MAX sentinel branch is deleted (crawl_peers now returns Result, sole call site updated).

Tests (laptop, targeted)

  • cargo test --lib depth — 3/3 pass, including the new test_cli_peers_depth_rejects_negative_and_preserves_non_negative_values (both negative forms refused, error names depth; 0/1/2 preserved) and crawl_peers_refuses_negative_depth_before_networking.
  • cargo test --lib cli:: — 121/121 pass. cargo test --lib commands::peers — 14/14 pass.

One fix during verification: without allow_negative_numbers, the space form --depth -1 was refused by clap as "unexpected argument" — refused, but with an error that did not name the constraint, failing the acceptance wording. The flag makes clap hand -1 to the range parser, which refuses it naming --depth.

Full CI on the PR covers the remaining pkgs/id suites. Merge follows the Codex findings gate.


View with [code]smith Autofix with [code]smith
Need help on this PR? Tag @codesmith-bot with what you need.

@dezren39
dezren39 requested a review from a team as a code owner November 2, 2026 00:38
@chatgpt-codex-connector

chatgpt-codex-connector Bot commented Nov 2, 2026 •

Copy link
Copy Markdown

Codex Review Summary

This comment shows the latest Codex review activity on this pull request.

Review Status Commit Review trigger
📝 Code Review ✅ Completed 2026-11-02T00:40:46.692383Z b18e350 PR opened
ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review" or "@codex security review".

Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings.

@coderabbitai

coderabbitai Bot commented Nov 2, 2026

Copy link
Copy Markdown

Warning

Review limit reached

You've used all free OSS reviews for now. Wait for the free limit to reset to keep reviewing this public repository.

Next included review available in 32 minutes.

Check out review usage here.

View limit details

Limit details: You’ve used the included review currently available.

Learn how review limits work.

Review configuration:

Run configuration
  • Source mode: Auto
  • Repository: Unavailable
  • Branch: Unavailable
  • File: No configuration file from this repository applied
  • Commit: Unavailable
  • Layers: defaults
  • Review profile: CHILL
  • Plan: Advanced
  • Run ID: 0871a387-bd2e-4d12-8231-9c39b4fca00b
Commits

Reviewing files that changed from the base of the PR and between 8703ee5 and b18e350.

Files selected for processing: 2
  • pkgs/id/src/cli.rs
  • pkgs/id/src/commands/peers.rs
  • Autofix · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

Share

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant